package com.bkgy.modularbx.coil_track_fullproc.controller;

import com.bkgy.commom.model.QueryDTO;
import com.bkgy.modularbx.coil_track_fullproc.dto.CoilTrackingExportDTO;
import com.bkgy.modularbx.coil_track_fullproc.dto.CoilTrackingQueryDTO;
import com.bkgy.modularbx.coil_track_fullproc.service.TCoilTrackingFullprocService;
import com.bkgy.sys.common.entity.ResultData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 钢卷分卷全流程控制器层
 *
 * @author dell
 * @date 2024-03-21
 */
@Tag(name = "钢卷分卷全流程管理", description = "钢卷分卷全流程接口")
@RestController
@RequestMapping("/coil_fullproc")
@Validated
public class TCoilTrackingFullprocController {

    @Resource
    private TCoilTrackingFullprocService coilTrackingFullprocService;

    @Operation(summary = "分页查询钢卷分卷全流程信息", description = "根据条件分页查询钢卷分卷全流程信息")
   @ApiResponse(content = @Content(mediaType = "application/json",
        schema = @Schema(implementation = CoilTrackingExportDTO.class)))
    @PostMapping("/page")
    public ResultData<CoilTrackingExportDTO> page(
        @Parameter(description = "查询条件和分页信息") 
        @RequestBody @Valid QueryDTO<CoilTrackingQueryDTO> queryDTO) {
        return coilTrackingFullprocService.pageCoilTrackingFullproc(queryDTO);
    }

    @Operation(summary = "通过Excel模板导出全流程数据", description = "使用自定义Excel模板导出全流程数据")
    @PostMapping("/export-by-template")
    public void exportByTemplate(
        @Parameter(description = "查询条件和分页信息") 
        @RequestBody @Valid QueryDTO<CoilTrackingQueryDTO> queryDTO) {
        coilTrackingFullprocService.exportByTemplate(queryDTO);
    }
}